#include <iostream>
#include <memory>
using namespace std;
//认识weak_ptr，并且实验出它和shared_ptr,unique_ptr的区别
//weak_ptr就是为了解决shared_ptr循环引用的问题而诞生的
void test(){
shared_ptr<int> sp(new int(10));
weak_ptr<int> wp=sp;
cout<<sp.use_count()<<endl;
cout<<wp.use_count()<<endl;

shared_ptr<int> sp2=wp.lock();
cout<<wp.use_count()<<endl;
cout<<sp.use_count()<<endl;
cout<<sp2.use_count()<<endl;
}
int main(int argc, char * argv[]){
    test();
    return 0;
}

